package com.tianhui.consignortwofei.mvp.ui.adapter;

import android.content.Context;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.TextView;

import com.tianhui.consignortwofei.R;
import com.tianhui.consignortwofei.mvp.model.enty.HeDanListBean;
import com.tianhui.consignortwofei.pattern.orderStatus.status.IOrderStatus;

import org.yczbj.ycrefreshviewlib.adapter.RecyclerArrayAdapter;
import org.yczbj.ycrefreshviewlib.holder.BaseViewHolder;

/**
 * @author fgs
 * @date 2020/8/27
 * @description
 **/
public class HeDanListAdapter extends RecyclerArrayAdapter<HeDanListBean> {
    private IOrderStatus iOrderStatus;

    public HeDanListAdapter(Context context, IOrderStatus iOrderStatus) {
        super(context);
        this.iOrderStatus = iOrderStatus;
    }

    @Override
    public BaseViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) {
        return new HeDanListListViewHolder(parent, R.layout.item_hedan_list);
    }

    private class HeDanListListViewHolder extends BaseViewHolder<HeDanListBean> {

//        private ImageView iv_head;
//        private TextView tv_name;
//        private TextView tv_license;
//        private TextView tv_zhuangtai;
//        private TextView tv_zhuang_dress_one;
//        private TextView tv_zhuang_dress_two;
//        private TextView tv_zhuang_xie_one;
//        private TextView tv_zhuang_xie_two;
//        private LinearLayout ll_driver_line_body;
//        private TextView tv_yunfei;
//        private TextView tv_pay_type;
//
//        private TextView tv_guanli;
//        private TextView tv_cancel;
//        private TextView tv_true_shou;
//        private TextView tv_true_zhuang;
//        private TextView tv_xiashou_num;
        private EditText et_danhao;
        private EditText et_weight;
        private TextView tv_delete;
        private TextView tv_num;





        public HeDanListListViewHolder(ViewGroup parent, int res) {
            super(parent, res);

            et_danhao = getView(R.id.et_danhao);
            et_weight = getView(R.id.et_weight);
            tv_delete = getView(R.id.tv_delete);
            tv_num = getView(R.id.tv_num);

//            tv_guanli = getView(R.id.tv_guanli);
//            tv_cancel = getView(R.id.tv_cancel);
//            tv_true_shou = getView(R.id.tv_true_shou);
//            tv_true_zhuang = getView(R.id.tv_true_zhuang);
//            tv_xiashou_num = getView(R.id.tv_xiashou_num);
//            tv_change_price = getView(R.id.tv_change_price);
//            tv_change_weight= getView(R.id.tv_change_weight);
//            tv_change_hedan= getView(R.id.tv_change_hedan);


            addOnClickListener(R.id.tv_delete);
//            addOnClickListener(R.id.ll_driver_line_body);
//            addOnClickListener(R.id.tv_guanli);
//            addOnClickListener(R.id.tv_cancel);
//            addOnClickListener(R.id.tv_true_shou);


        }

        @Override
        public void setData(HeDanListBean data) {
            super.setData(data);


            et_danhao.setText(data.getBusinessno());
            et_weight.setText(data.getWeight());

            if (0==getAdapterPosition()){
                et_danhao.setEnabled(false);
                et_weight.setEnabled(false);
            }
            int num = getAdapterPosition() + 1;
            tv_num.setText(num+".");

            et_danhao.addTextChangedListener(new TextWatcher() {
                @Override
                public void beforeTextChanged(CharSequence s, int start, int count, int after) {

                }

                @Override
                public void onTextChanged(CharSequence s, int start, int before, int count) {

                }

                @Override
                public void afterTextChanged(Editable s) {
                    data.setBusinessno(s.toString());
                }
            });

            et_weight.addTextChangedListener(new TextWatcher() {
                @Override
                public void beforeTextChanged(CharSequence s, int start, int count, int after) {

                }

                @Override
                public void onTextChanged(CharSequence s, int start, int before, int count) {

                }

                @Override
                public void afterTextChanged(Editable s) {
                    data.setWeight(s.toString());
                }
            });

//            tv_name.setText(data.drivername);
//            tv_license.setText(data.vehiclenum);
//            tv_zhuang_dress_one.setText(data.deliverprovince + data.delivercity + data.delivercounty + data.deliverdetails);
//            tv_zhuang_dress_two.setText(data.delivercity + data.delivercounty+data.lendtime+"前");
//            tv_zhuang_xie_one.setText(data.destinationprovince + data.destinationcity + data.destinationcounty + data.destinationdetails);
//            tv_zhuang_xie_two.setText(data.destinationcity + data.destinationcounty);
//
//            tv_yunfei.setText("￥"+data.totalprice);
//            tv_zhuangtai.setText(data.isstatetext);
//            tv_change_price.setVisibility(View.GONE);
//            tv_change_weight.setVisibility(View.GONE);
//            tv_change_hedan.setVisibility(View.GONE);
//
//            int orderStatusType = iOrderStatus.getFeiOrderType();
//
//
//            if (null!=data.businessno&&!TextUtils.isEmpty(data.businessno)){
//                tv_xiashou_num.setVisibility(View.VISIBLE);
//                tv_xiashou_num.setText("销售单号："+data.businessno);
//            }else {
//                tv_xiashou_num.setVisibility(View.GONE);
//            }



        }
    }
}
